package com.atguigu.gmall.user.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.user.entity.UserAddress;
import com.atguigu.gmall.user.service.UserAddressService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api/inner/rpc/user")
@RestController
public class UserRpcController {

    @Autowired
    UserAddressService userAddressService;

    @ApiOperation("获取用户收货地址列表")
    @RequestMapping("/addresses/{userId}")
    public Result<List<UserAddress>> getUserAddress (@PathVariable("userId") Long userId){
        List<UserAddress> userAddressList = userAddressService.lambdaQuery().eq(UserAddress::getUserId, userId).list();
        return Result.ok(userAddressList);
    }
}
